package com.javatest.chapter2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author liuziyang
 * @create 2020-03-29 14:31
 */
public class Sample2 {
    public static void main(String[] args) throws InterruptedException {
        final long start = System.currentTimeMillis();

        //1.开启异步单元执行任务a
        Thread thread = new Thread(() -> {
            WorkExecutor.doSomethingA();
        }, "thread-a");
        thread.start();

        //执行任务B
        WorkExecutor.doSomethingB();

        //3.同步等待线程a运行结束
        thread.join();
        System.out.println("[totoal time in ms]:" + (System.currentTimeMillis() - start));
    }
}
